<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;
/**
 */
class CpsWallet extends Model
{
    protected $connection = 'spread';
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'cps_wallet';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [];
    protected $guarded = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [];


    /**
     * @param $id
     * @return \Hyperf\Database\Model\Builder|\Hyperf\Database\Model\Model|object|null
     */
    public function getInfoById($id)
    {
        return self::where('s_id',$id)->first();
    }

    /**
     * 增加inc
     * @param $userId
     * @param $num
     * @return int
     */
    public function incCoinByUserId($userId, $num): int
    {
        return $this->where('s_id', $userId)->increment('balance', $num);
    }
}